3.683 \(\int \frac{(a+b \sin (e+f x))^2}{(c+d \sin (e+f x))^2} \, dx\)

Optimal. Leaf size=129 \[ -\frac{2 (b c-a d) \left (a c d+b \left (c^2-2 d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2 f \left (c^2-d^2\right )^{3/2}}+\frac{(b c-a d)^2 \cos (e+f x)}{d f \left (c^2-d^2\right ) (c+d \sin (e+f x))}+\frac{b^2 x}{d^2} \]

[Out]

(b^2*x)/d^2 - (2*(b*c - a*d)*(a*c*d + b*(c^2 - 2*d^2))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(d^2*
(c^2 - d^2)^(3/2)*f) + ((b*c - a*d)^2*Cos[e + f*x])/(d*(c^2 - d^2)*f*(c + d*Sin[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.23082, antiderivative size = 129, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 5, integrand size = 25, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.2, Rules used = {2790, 2735, 2660, 618, 204} \[ -\frac{2 (b c-a d) \left (a c d+b \left (c^2-2 d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2 f \left (c^2-d^2\right )^{3/2}}+\frac{(b c-a d)^2 \cos (e+f x)}{d f \left (c^2-d^2\right ) (c+d \sin (e+f x))}+\frac{b^2 x}{d^2} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Sin[e + f*x])^2/(c + d*Sin[e + f*x])^2,x]

[Out]

(b^2*x)/d^2 - (2*(b*c - a*d)*(a*c*d + b*(c^2 - 2*d^2))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(d^2*
(c^2 - d^2)^(3/2)*f) + ((b*c - a*d)^2*Cos[e + f*x])/(d*(c^2 - d^2)*f*(c + d*Sin[e + f*x]))

Rule 2790

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> -Simp[
((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1))/(b*f*(m + 1)*(a^2 - b^2)), x] - Di
st[1/(b*(m + 1)*(a^2 - b^2)), Int[(a + b*Sin[e + f*x])^(m + 1)*Simp[b*(m + 1)*(2*b*c*d - a*(c^2 + d^2)) + (a^2
*d^2 - 2*a*b*c*d*(m + 2) + b^2*(d^2*(m + 1) + c^2*(m + 2)))*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e,
f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && LtQ[m, -1]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{(a+b \sin (e+f x))^2}{(c+d \sin (e+f x))^2} \, dx &=\frac{(b c-a d)^2 \cos (e+f x)}{d \left (c^2-d^2\right ) f (c+d \sin (e+f x))}+\frac{\int \frac{d \left (\left (a^2+b^2\right ) c-2 a b d\right )+b^2 \left (c^2-d^2\right ) \sin (e+f x)}{c+d \sin (e+f x)} \, dx}{d \left (c^2-d^2\right )}\\ &=\frac{b^2 x}{d^2}+\frac{(b c-a d)^2 \cos (e+f x)}{d \left (c^2-d^2\right ) f (c+d \sin (e+f x))}-\frac{\left (-d^2 \left (\left (a^2+b^2\right ) c-2 a b d\right )+b^2 c \left (c^2-d^2\right )\right ) \int \frac{1}{c+d \sin (e+f x)} \, dx}{d^2 \left (c^2-d^2\right )}\\ &=\frac{b^2 x}{d^2}+\frac{(b c-a d)^2 \cos (e+f x)}{d \left (c^2-d^2\right ) f (c+d \sin (e+f x))}-\frac{\left (2 \left (-d^2 \left (\left (a^2+b^2\right ) c-2 a b d\right )+b^2 c \left (c^2-d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+2 d x+c x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^2 \left (c^2-d^2\right ) f}\\ &=\frac{b^2 x}{d^2}+\frac{(b c-a d)^2 \cos (e+f x)}{d \left (c^2-d^2\right ) f (c+d \sin (e+f x))}+\frac{\left (4 \left (-d^2 \left (\left (a^2+b^2\right ) c-2 a b d\right )+b^2 c \left (c^2-d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{-4 \left (c^2-d^2\right )-x^2} \, dx,x,2 d+2 c \tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^2 \left (c^2-d^2\right ) f}\\ &=\frac{b^2 x}{d^2}-\frac{2 (b c-a d) \left (b c^2+a c d-2 b d^2\right ) \tan ^{-1}\left (\frac{d+c \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c^2-d^2}}\right )}{d^2 \left (c^2-d^2\right )^{3/2} f}+\frac{(b c-a d)^2 \cos (e+f x)}{d \left (c^2-d^2\right ) f (c+d \sin (e+f x))}\\ \end{align*}

Mathematica [A]  time = 0.52621, size = 134, normalized size = 1.04 \[ \frac{-\frac{2 \left (-a^2 c d^2+2 a b d^3+b^2 \left (c^3-2 c d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{\left (c^2-d^2\right )^{3/2}}+\frac{d (b c-a d)^2 \cos (e+f x)}{(c-d) (c+d) (c+d \sin (e+f x))}+b^2 (e+f x)}{d^2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Sin[e + f*x])^2/(c + d*Sin[e + f*x])^2,x]

[Out]

(b^2*(e + f*x) - (2*(-(a^2*c*d^2) + 2*a*b*d^3 + b^2*(c^3 - 2*c*d^2))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2
- d^2]])/(c^2 - d^2)^(3/2) + (d*(b*c - a*d)^2*Cos[e + f*x])/((c - d)*(c + d)*(c + d*Sin[e + f*x])))/(d^2*f)

________________________________________________________________________________________

Maple [B]  time = 0.082, size = 556, normalized size = 4.3 \begin{align*} 2\,{\frac{{d}^{2}\tan \left ( 1/2\,fx+e/2 \right ){a}^{2}}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) c}}-4\,{\frac{\tan \left ( 1/2\,fx+e/2 \right ) dab}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) }}+2\,{\frac{c\tan \left ( 1/2\,fx+e/2 \right ){b}^{2}}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) }}+2\,{\frac{{a}^{2}d}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) }}-4\,{\frac{abc}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) }}+2\,{\frac{{c}^{2}{b}^{2}}{df \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ({c}^{2}-{d}^{2} \right ) }}+2\,{\frac{{a}^{2}c}{f \left ({c}^{2}-{d}^{2} \right ) ^{3/2}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }-4\,{\frac{abd}{f \left ({c}^{2}-{d}^{2} \right ) ^{3/2}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }-2\,{\frac{{b}^{2}{c}^{3}}{f{d}^{2} \left ({c}^{2}-{d}^{2} \right ) ^{3/2}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+4\,{\frac{{b}^{2}c}{f \left ({c}^{2}-{d}^{2} \right ) ^{3/2}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+2\,{\frac{{b}^{2}\arctan \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) }{f{d}^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*sin(f*x+e))^2/(c+d*sin(f*x+e))^2,x)

[Out]

2/f*d^2/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)/c*tan(1/2*f*x+1/2*e)*a^2-4/f*d/(c*tan(1/2*
f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*tan(1/2*f*x+1/2*e)*a*b+2/f/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*
f*x+1/2*e)*d+c)/(c^2-d^2)*c*tan(1/2*f*x+1/2*e)*b^2+2/f*d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^
2-d^2)*a^2-4/f/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*a*b*c+2/f/d/(c*tan(1/2*f*x+1/2*e)^2
+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*c^2*b^2+2/f/(c^2-d^2)^(3/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-
d^2)^(1/2))*a^2*c-4/f*d/(c^2-d^2)^(3/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*a*b-2/f/d^2/(
c^2-d^2)^(3/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*b^2*c^3+4/f/(c^2-d^2)^(3/2)*arctan(1/2
*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*b^2*c+2/f*b^2/d^2*arctan(tan(1/2*f*x+1/2*e))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2/(c+d*sin(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 1.99023, size = 1434, normalized size = 11.12 \begin{align*} \left [\frac{2 \,{\left (b^{2} c^{4} d - 2 \, b^{2} c^{2} d^{3} + b^{2} d^{5}\right )} f x \sin \left (f x + e\right ) + 2 \,{\left (b^{2} c^{5} - 2 \, b^{2} c^{3} d^{2} + b^{2} c d^{4}\right )} f x -{\left (b^{2} c^{4} + 2 \, a b c d^{3} -{\left (a^{2} + 2 \, b^{2}\right )} c^{2} d^{2} +{\left (b^{2} c^{3} d + 2 \, a b d^{4} -{\left (a^{2} + 2 \, b^{2}\right )} c d^{3}\right )} \sin \left (f x + e\right )\right )} \sqrt{-c^{2} + d^{2}} \log \left (-\frac{{\left (2 \, c^{2} - d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2} - 2 \,{\left (c \cos \left (f x + e\right ) \sin \left (f x + e\right ) + d \cos \left (f x + e\right )\right )} \sqrt{-c^{2} + d^{2}}}{d^{2} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2}}\right ) + 2 \,{\left (b^{2} c^{4} d - 2 \, a b c^{3} d^{2} + 2 \, a b c d^{4} - a^{2} d^{5} +{\left (a^{2} - b^{2}\right )} c^{2} d^{3}\right )} \cos \left (f x + e\right )}{2 \,{\left ({\left (c^{4} d^{3} - 2 \, c^{2} d^{5} + d^{7}\right )} f \sin \left (f x + e\right ) +{\left (c^{5} d^{2} - 2 \, c^{3} d^{4} + c d^{6}\right )} f\right )}}, \frac{{\left (b^{2} c^{4} d - 2 \, b^{2} c^{2} d^{3} + b^{2} d^{5}\right )} f x \sin \left (f x + e\right ) +{\left (b^{2} c^{5} - 2 \, b^{2} c^{3} d^{2} + b^{2} c d^{4}\right )} f x +{\left (b^{2} c^{4} + 2 \, a b c d^{3} -{\left (a^{2} + 2 \, b^{2}\right )} c^{2} d^{2} +{\left (b^{2} c^{3} d + 2 \, a b d^{4} -{\left (a^{2} + 2 \, b^{2}\right )} c d^{3}\right )} \sin \left (f x + e\right )\right )} \sqrt{c^{2} - d^{2}} \arctan \left (-\frac{c \sin \left (f x + e\right ) + d}{\sqrt{c^{2} - d^{2}} \cos \left (f x + e\right )}\right ) +{\left (b^{2} c^{4} d - 2 \, a b c^{3} d^{2} + 2 \, a b c d^{4} - a^{2} d^{5} +{\left (a^{2} - b^{2}\right )} c^{2} d^{3}\right )} \cos \left (f x + e\right )}{{\left (c^{4} d^{3} - 2 \, c^{2} d^{5} + d^{7}\right )} f \sin \left (f x + e\right ) +{\left (c^{5} d^{2} - 2 \, c^{3} d^{4} + c d^{6}\right )} f}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2/(c+d*sin(f*x+e))^2,x, algorithm="fricas")

[Out]

[1/2*(2*(b^2*c^4*d - 2*b^2*c^2*d^3 + b^2*d^5)*f*x*sin(f*x + e) + 2*(b^2*c^5 - 2*b^2*c^3*d^2 + b^2*c*d^4)*f*x -
 (b^2*c^4 + 2*a*b*c*d^3 - (a^2 + 2*b^2)*c^2*d^2 + (b^2*c^3*d + 2*a*b*d^4 - (a^2 + 2*b^2)*c*d^3)*sin(f*x + e))*
sqrt(-c^2 + d^2)*log(-((2*c^2 - d^2)*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2 - 2*(c*cos(f*x + e)*sin(f
*x + e) + d*cos(f*x + e))*sqrt(-c^2 + d^2))/(d^2*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2)) + 2*(b^2*c^
4*d - 2*a*b*c^3*d^2 + 2*a*b*c*d^4 - a^2*d^5 + (a^2 - b^2)*c^2*d^3)*cos(f*x + e))/((c^4*d^3 - 2*c^2*d^5 + d^7)*
f*sin(f*x + e) + (c^5*d^2 - 2*c^3*d^4 + c*d^6)*f), ((b^2*c^4*d - 2*b^2*c^2*d^3 + b^2*d^5)*f*x*sin(f*x + e) + (
b^2*c^5 - 2*b^2*c^3*d^2 + b^2*c*d^4)*f*x + (b^2*c^4 + 2*a*b*c*d^3 - (a^2 + 2*b^2)*c^2*d^2 + (b^2*c^3*d + 2*a*b
*d^4 - (a^2 + 2*b^2)*c*d^3)*sin(f*x + e))*sqrt(c^2 - d^2)*arctan(-(c*sin(f*x + e) + d)/(sqrt(c^2 - d^2)*cos(f*
x + e))) + (b^2*c^4*d - 2*a*b*c^3*d^2 + 2*a*b*c*d^4 - a^2*d^5 + (a^2 - b^2)*c^2*d^3)*cos(f*x + e))/((c^4*d^3 -
 2*c^2*d^5 + d^7)*f*sin(f*x + e) + (c^5*d^2 - 2*c^3*d^4 + c*d^6)*f)]

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))**2/(c+d*sin(f*x+e))**2,x)

[Out]

Timed out

________________________________________________________________________________________

Giac [B]  time = 1.38909, size = 336, normalized size = 2.6 \begin{align*} \frac{\frac{{\left (f x + e\right )} b^{2}}{d^{2}} - \frac{2 \,{\left (b^{2} c^{3} - a^{2} c d^{2} - 2 \, b^{2} c d^{2} + 2 \, a b d^{3}\right )}{\left (\pi \left \lfloor \frac{f x + e}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (c\right ) + \arctan \left (\frac{c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + d}{\sqrt{c^{2} - d^{2}}}\right )\right )}}{{\left (c^{2} d^{2} - d^{4}\right )} \sqrt{c^{2} - d^{2}}} + \frac{2 \,{\left (b^{2} c^{2} d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - 2 \, a b c d^{2} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + a^{2} d^{3} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + b^{2} c^{3} - 2 \, a b c^{2} d + a^{2} c d^{2}\right )}}{{\left (c^{3} d - c d^{3}\right )}{\left (c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} + 2 \, d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + c\right )}}}{f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2/(c+d*sin(f*x+e))^2,x, algorithm="giac")

[Out]

((f*x + e)*b^2/d^2 - 2*(b^2*c^3 - a^2*c*d^2 - 2*b^2*c*d^2 + 2*a*b*d^3)*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn(c
) + arctan((c*tan(1/2*f*x + 1/2*e) + d)/sqrt(c^2 - d^2)))/((c^2*d^2 - d^4)*sqrt(c^2 - d^2)) + 2*(b^2*c^2*d*tan
(1/2*f*x + 1/2*e) - 2*a*b*c*d^2*tan(1/2*f*x + 1/2*e) + a^2*d^3*tan(1/2*f*x + 1/2*e) + b^2*c^3 - 2*a*b*c^2*d +
a^2*c*d^2)/((c^3*d - c*d^3)*(c*tan(1/2*f*x + 1/2*e)^2 + 2*d*tan(1/2*f*x + 1/2*e) + c)))/f